import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';

///@date:  2025/1/22
///@author:  leisiyu
///@description: Future扩展
extension FutureExtension<T> on Future<T> {
  Future<T> withLoading({String loadingText = "加载中..."}) async {
    SmartDialog.showLoading(
      useAnimation: false,
      msg: loadingText,
      clickMaskDismiss: false,
      backDismiss: false,
    );
    try {
      return await this;
    } finally {
      await SmartDialog.dismiss(status: SmartStatus.loading);
    }
  }
}